package org.faesa.masterSlave.common;

import java.io.Serializable;

public class SlaveId implements Serializable {
	private static final long serialVersionUID = 5560590096934454111L;
	private static int currId = 0;
	private int id;
	
	public SlaveId() {
		this.id = SlaveId.getCurrentId();
	}
	
	private synchronized static int getCurrentId() {
		return ++SlaveId.currId;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SlaveId other = (SlaveId) obj;
		if (id != other.id)
			return false;
		return true;
	}
	@Override
	public String toString() {
		return "SlaveId [id=" + id + "]";
	}	
}
